﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CTEM.Controllers.BUS;
using CTEM.Controllers.Global;
using CTEM.Models;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;

namespace CTEM.ModuleForms.ManageRole
{
    public partial class DXSetRight : DevExpress.XtraEditors.XtraForm
    {
        List<RoleDTO> _listRole;
        List<RightDTO> _listRights;
        long RoleID;
        long rightValue;
        RoleBUS roleBUS = new RoleBUS();
        RightBUS rightBUS = new RightBUS();
        public DXSetRight(List<RoleDTO> listRole)
        {
            
            _listRole = listRole;
            _listRights = rightBUS.LoadAllRight();
            roleDTOBindingSource.DataSource = _listRole;
            InitializeComponent();

        }
        public DXSetRight(long _RoleID, long _rightValue, List<RoleDTO> listRole)
        {
            RoleID = _RoleID;
            rightValue = _rightValue;
            _listRole = listRole;
            _listRights = rightBUS.LoadAllRight();
            BindingSource roleSource = new BindingSource();
            roleSource.DataSource = listRole;
            

            cbxRole.DataBindings.Add("EditValue", roleSource, "RoleID");
            cbxRole.Properties.DisplayMember = Constants.ROLE_DISPLAYMEMBER;
            cbxRole.Properties.ValueMember = Constants.ROLE_VALUEMEMBER;
            LookUpColumnInfoCollection coll = cbxRole.Properties.Columns;
            // A column to display the ProductID field's values.
            coll.Add(new LookUpColumnInfo("RoleID", 0));
            // A column to display the ProductName field's values.
            coll.Add(new LookUpColumnInfo("RoleName", 0));
            //cbxRole.Properties.DataSource = new List<RoleDTO>();
            //cbxRole.Properties.DataSource = listRole;
            
            //rightDTOBindingSource.DataSource = _listRights;
            cbxRole.Properties.DataSource = roleSource;
            cbxRights.Properties.DataSource = _listRights;
            lbxRights.DataSource = rightBUS.GetRightByRole(rightValue);
            //comboBoxEdit1.ItemIndex = _listRole.IndexOf()
            InitializeComponent();
            
        }
    }
}